<!--
 * @Author: luoyun
 * @Descripttion: 
-->
<template>
  <ul class="tab-control">
      <li 
        v-for="(item,index) in title" 
        :key="index"
        :class="{active:index === currentIndex }" 
        @click="tabClick(index)"> 
        <span>{{item}}</span>
      </li>
    </ul>
</template>

<script>
  export default {
    name:'TabControl',
    props:{
      title:{
        type:Array,
        default:() => {
          return []
        }
      }
    },
    data () {
      return {
        currentIndex:0
      };
    },

    components:{},

    methods:{
      tabClick(index){
        this.currentIndex = index
        this.$emit('tabItemClick',index)
      }
    },

    created(){}
  }
</script>

<style lang='scss' scoped>
  .tab-control{
    display: flex;
    background:#fff;
    width:100vw;
    li{
      flex:1;
      display: flex;
      align-items: center;
      justify-content: center;
      height:40px;
      
    }
  }
  .active{
    >span{
      border-bottom:1px solid red;
      display: block;
      border-bottom:3px solid var(--color-high-text);
    }
  }
</style>